package cool.tianyou.blue.bird.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.RequiresApi;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import cool.tianyou.blue.bird.DatabaseHelper;
import cool.tianyou.blue.bird.R;
import cool.tianyou.blue.bird.model.Log;
import cool.tianyou.blue.bird.util.LogUtil;


public class SmsListAdapter extends BaseAdapter implements AbsListView.OnScrollListener {

    private final List<Log> logs;
    private final DatabaseHelper databaseHelper;

    private final LayoutInflater mLayoutInflate;
    private final Context context;

    public SmsListAdapter(DatabaseHelper databaseHelper, Context context) {
        this.logs = new ArrayList<>();
        this.databaseHelper = databaseHelper;
        mLayoutInflate = LayoutInflater.from(context);
        this.context = context;
    }

    @Override
    public int getCount() {
        return logs.size();
    }

    @Override
    public Object getItem(int position) {
        return logs.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("ViewHolder")
    @RequiresApi(api = Build.VERSION_CODES.N)
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (position >= logs.size()) {
            return null;
        }
        Log log = logs.get(position);
        convertView = mLayoutInflate.inflate(R.layout.list_item_layout, parent, false);

        return convertView;
    }


    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

    }
}
